package com.innovation.chengzhangriji.http;

import com.google.gson.annotations.SerializedName;
import com.innovation.chengzhangriji.Config;
import com.innovation.chengzhangriji.ConfigurationManager;
import com.innovation.library.http.InnovationRequestBody;

public class CheckVersionRequest extends BaseRequest {

    public static final String PATH;

    static {
//        switch (com.innovation.chengzhangriji.Flavors.URL_TYPE) {
//            case Config.URL_DEV:
//                PATH = "http://apiint.iemylife.com/api/Check_Versions";
//                break;
//            case Config.URL_TEST:
//                PATH = "http://apiint.iemylife.com/api/Check_Versions";
//                break;
//            case Config.URL_OFFICIAL:
//                PATH = "https://api.iemylife.com/api/Check_Versions";
//                break;
//            default:
//                PATH = "https://api.iemylife.com/api/Check_Versions";
//                break;
//        }
        PATH = Config.getConfig(ConfigurationManager.UPDATE_URL);
    }

    private String packageName;

    private String version;

    private String channel;

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    @Override
    protected InnovationRequestBody getInnovationRequestBody() {
        CheckVersionRequestBody body = new CheckVersionRequestBody();
        body.setPackageName(getPackageName());
        body.setVersion(getVersion());
        body.setChannel(getChannel());
        return body;
    }

    private class CheckVersionRequestBody extends BaseRequestBody {

        @SerializedName("SystemEnvironments")
        private String packageName;

        @SerializedName("VersionNumber")
        private String version;

        @SerializedName("VersionParameter")
        private String channel;

        private CheckVersionRequestBody() {
            setSv(BaseRequestConfig.SV_CHECK_VERSION);
        }

        public String getPackageName() {
            return packageName;
        }

        public void setPackageName(String packageName) {
            this.packageName = packageName;
        }

        public String getVersion() {
            return version;
        }

        public void setVersion(String version) {
            this.version = version;
        }

        public String getChannel() {
            return channel;
        }

        public void setChannel(String channel) {
            this.channel = channel;
        }
    }
}
